  
function gmap(api)
{
	this.map = null;
	this.scale = 100.0;
	this.api = api;
	var markers = [];
	
	this.init = function initialize() 
	{
		var latlng = new google.maps.LatLng(0.0, 0.0);
	    var myOptions = {
	    		zoom: 5,
	    		center: latlng,
	    		mapTypeControl: false,
	    		mapTypeId: google.maps.MapTypeId.ROADMAP
	    		};
	    this.map = new google.maps.Map(document.getElementById("gmap"), myOptions);
	    this.makeback();
	};
	
	this.add_ent = function add_point(ent)
	{
		var x = ent.x/this.scale;
		var y = ent.y/this.scale;
		var t = ent.idx.toString();
		var p = new google.maps.LatLng(y,x);
		var image = 'img/firstaid.png';
		if (ent.type == 'ship')
		{
			if(ent.player == this.api.player)
			{
				image = 'img/panoramic.png';
			}
			else
			{
				image = 'img/archery.png';
			}
		}
		else if(ent.type == 'base')
		{
			if(ent.player == this.api.player)
			{
				image = 'img/bank.png';
			}
			else
			{
				image = 'img/firstaid.png';
			}
		}
		else
		{
			image = 'img/mine.png';
		}
		
		var m = new google.maps.Marker({
			position: p, 
			map: this.map, 
			title:t,
			icon:image
		});
		
		this.markers.push(m);
		
	};
	
	this.update = function update()
	{
		for (var i in this.markers)
		{
			this.markers[i].setMap(null);
		}
		this.markers = [];
		
		for(var i in this.api.entities)
		{
			this.add_ent(this.api.entities[i]);
		}
	};
	
	this.makeback = function makeback()
	{
		  var tc = [new google.maps.LatLng(90.0, -180.0),
		            new google.maps.LatLng(90.0, 0.0),
		            new google.maps.LatLng(-90.0, 0.0),
		            new google.maps.LatLng(-90.0, -180.0),
		  			new google.maps.LatLng(90.0, -180.0)];

          // Construct the polygon
          // Note that we don't specify an array or arrays, but instead just
          // a simple array of LatLngs in the paths property
          bt = new google.maps.Polygon({
            paths: tc,
            strokeColor: "#cccccc",
            strokeOpacity: 1.0,
            strokeWeight: 1,
            fillColor: "#cccccc",
            fillOpacity: 1.0
          });

          bt.setMap(this.map);
          
		  var tc2 = [new google.maps.LatLng(90.0, 180.0),
		            new google.maps.LatLng(90.0,0.0),
		            new google.maps.LatLng(-90.0,0.0),
		            new google.maps.LatLng(-90.0, 180.0),
		  			new google.maps.LatLng(90.0, 180.0)];

          // Construct the polygon
          // Note that we don't specify an array or arrays, but instead just
          // a simple array of LatLngs in the paths property
          bt2 = new google.maps.Polygon({
            paths: tc2,
            strokeColor: "#cccccc",
            strokeOpacity: 1.0,
            strokeWeight: 1,
            fillColor: "#cccccc",
            fillOpacity: 1.0
          });

          bt2.setMap(this.map);	
	};
	
}




